<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.saving}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            
            <h:form>
               <script type="text/javascript">
                    function handleDlgsaving(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                           dlgsaving.hide();  
                        }  
                    }
                </script> 
<!--               update=":#{utilityBean.findClientId('displaySavapproval')}"-->
                <p:toolbar>
                    <p:toolbarGroup align="left">    
                        <p:commandButton value="#{bundle.btnOpen}" icon="ui-icon-disk" oncomplete="dlgsaving.show();"
                                         actionListener="#{savingApprovalBean.openData()}" 
                                         rendered="#{menuBean.cekButtonAccess(101,'APP;')}"
                                         update=":#{utilityBean.findClientId('displaySavapproval')}"> 
                        </p:commandButton>
                        
                        <p:commandButton value="Refresh" icon="ui-icon-arrowrefresh-1-w" update=":#{utilityBean.findClientId('dtSavapprovals')}" 
                                         actionListener="#{savingApprovalBean.loadSavings()}" >
                        </p:commandButton>
                        
                    </p:toolbarGroup>
                </p:toolbar>
                <h:panelGrid cellpadding="3" />
                
                <p:dataTable id="dtSavapprovals" value="#{savingApprovalBean.savings}" var="savapprove" 
                             selection="#{savingApprovalBean.saving}" selectionMode="single" rowIndexVar="noUrut"
                    rowKey="#{savapprove.savaccntId}" 
                    paginator="true" rows="10" paginatorPosition="bottom"  emptyMessage=""
                    paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {NextPageLink} "
                    resizableColumns="true">
                                        
                    <p:column style="width: 10px">
                        <f:facet name="header">No.</f:facet>
                        <h:outputText value="#{noUrut+1}" />
                    </p:column>
                    
                    <p:column style="width: 90px" sortBy="#{savapprove.accountNo}">
                        <f:facet name="header">#{bundle.savingNo}</f:facet>
                        <h:outputText value="#{savapprove.accountNo}" />
                    </p:column>

                    <p:column style="width: 90px" >
                        <f:facet name="header">#{bundle.cif}</f:facet>
                        <h:outputText value="#{savapprove.customer.cif}" />
                    </p:column>
                                        
                    <p:column style="width: 130px" >
                        <f:facet name="header">#{bundle.customer}</f:facet>
                        <h:outputText value="#{savapprove.customer.customerName}" />
                    </p:column>
                                        
                    <p:column style="width: 130px" >
                        <f:facet name="header">#{bundle.savprod}</f:facet>
                        <h:outputText value="#{savapprove.savprod.productName}" />
                    </p:column>

                    <p:column style="width: 80px" >
                        <f:facet name="header">#{bundle.openDate}</f:facet>
                        <h:outputText value="#{savapprove.openDate}" />
                    </p:column>
                </p:dataTable>
                </h:form>
            
<!--       rendered="#{savingApprovalBean.saving != null}"     -->
                <p:dialog header="Verifikasi #{approvalBean.approval.appName}" widgetVar="dlgsaving" closable="true" dynamic="true" 
                          appendToBody="true" modal="true" >
                    <p:ajax event="close" immediate="true" listener="#{savingApprovalBean.handleClose}"/>
                    <h:form>
                    <h:panelGrid id="displaySavapproval" columns="2" cellspacing="0" cellpadding="0" columnClasses="panelGridId, panelGridId" border="0" >
                        <p:panel header="#{bundle.savledgend}" style="margin: 0 0 0 0;"  >
                            <h:panelGrid columns="3" border="0" cellspacing="10" cellpadding="0" >
                                <h:outputLabel value= "#{bundle.cif}" /><h:outputLabel value= ":" />
                                <h:outputLabel value="#{savingApprovalBean.saving.customer.cif}" />

                                <h:outputLabel value="#{bundle.savprod}" /><h:outputLabel value= ":" />
                                <h:outputLabel value="#{savingApprovalBean.saving.savprod.productName}" />

                                <h:outputLabel value="#{bundle.openDate}" /><h:outputLabel value= ":" />
                                <h:outputText value="#{savingApprovalBean.saving.openDate}" />

                                <h:outputLabel value= "#{bundle.savingNo}" /><h:outputLabel value= ":" />
                                <h:outputLabel value="#{savingApprovalBean.saving.accountNo}" />

                                <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.savpurpose}" /><h:outputLabel value= ":" />
                                <h:outputLabel value="#{savingApprovalBean.saving.savpurpose.purposeName}" />

                                <h:outputLabel value="#{bundle.approvalUID}" /><h:outputLabel value= ":" />
                                <h:outputLabel value="#{loginBean.selectedUser.userName}" />

                                <h:outputLabel value="#{bundle.joinAccnt}" /><h:outputLabel value= ":" />
                                <p:selectBooleanCheckbox value="#{savingApprovalBean.saving.joinAccnt}" disabled="true" />

                                <h:outputLabel value="#{bundle.joinType}" /><h:outputLabel value= ":" />
                                <h:outputLabel value="#{constantaBean.getJointTypeText(savingApprovalBean.saving.joinType)}" />
                            </h:panelGrid>

                            <h:panelGrid columns="0" style="width: 100%;" >
                                <p:toolbar>
                                    <p:toolbarGroup align="left" >
                                        <h:outputText value="#{bundle.joinAccnt}" />
                                    </p:toolbarGroup>
                                </p:toolbar>

                                <p:dataTable var="savjoinapprov" value="#{savingApprovalBean.saving.savjoints}" rendered="#{savingApprovalBean.saving != null}" >
                                    <p:column headerText="#{bundle.cif}" style="width:100px">
                                        <h:outputText value="#{savjoinapprov.customer.cif}" style="width:100px;" />
                                    </p:column>

                                    <p:column style="width:auto" headerText="#{bundle.globalName}" >
                                        <h:outputLabel value="#{savjoinapprov.customer.customerName}" style="width:100px;" />
                                    </p:column> 
                                </p:dataTable>
                            </h:panelGrid>
                        </p:panel>
                        
                        <h:panelGrid columns="1" rowClasses="panelGridId" border="0" cellspacing="0" cellpadding="0" columnClasses="panelGridId, panelGridId">
                            <p:panel header="#{bundle.cusledgen}" rendered="#{savingApprovalBean.saving != null}" >
                                <h:panelGrid columns="3" style="width:100%;" cellspacing="10" cellpadding="0" >
                                    <h:outputLabel value= "#{bundle.globalName}" /><h:outputLabel value= ":" />
                                    <h:outputText style="padding: 0 75px 0 0;"  value="#{savingApprovalBean.saving.customer.customerName}" />

                                    <h:outputLabel value= "#{bundle.aliasName}" /><h:outputLabel value= ":" />
                                    <h:outputText rendered="true" value="#{savingApprovalBean.saving.customer.aliasName}" />

                                    <h:outputLabel value= "#{bundle.phone}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{savingApprovalBean.saving.customer.phone}"/> 

                                    <h:outputLabel value= "#{bundle.mobilePhone}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{savingApprovalBean.saving.customer.mobilePhone}"/>

                                    <h:outputLabel style="padding: 0 15px 0 0;"  value= "#{bundle.npwp}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{savingApprovalBean.saving.customer.npwp}" />

                                    <h:outputLabel style="padding: 0 15px 0 0;"  value= "#{bundle.addressRes}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{savingApprovalBean.saving.customer.idAddressLine1}" />
                                </h:panelGrid>
                            </p:panel>

                            <p:panel header="#{bundle.savprodLedgend}" rendered="#{savingApprovalBean.saving != null}" >
                                <h:panelGrid columns="3" style="width: 100%;" cellspacing="10" cellpadding="0" >
                                    <h:outputLabel value= "#{bundle.savprod}" /><h:outputLabel value=":" />
                                    <h:outputText rendered="true" value="#{savingApprovalBean.saving.savprod.productName}" />

                                    <h:outputLabel value= "#{bundle.minFirstDeposit}" /><h:outputLabel value=":" />
                                    <h:outputText styleClass="numPos" value="#{savingApprovalBean.saving.savprod.minFirstDeposit}" >
                                        <f:convertNumber groupingUsed="true" maxFractionDigits="4"/>
                                    </h:outputText>

                                    <h:outputLabel value= "#{bundle.minRegDeposit}" /><h:outputLabel value=":" />
                                    <h:outputText styleClass="numPos" value="#{savingApprovalBean.saving.savprod.minRegDeposit}" >
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>

                                    <h:outputLabel value= "#{bundle.interestTax}" /><h:outputLabel value=":" />
                                    <h:outputText styleClass="numPos" value="#{savingApprovalBean.getInterestTaxName(savingApprovalBean.saving.savprod.interestTaxId)} %" />

                                    <h:outputLabel value= "#{bundle.interestMethod}" /><h:outputLabel value=":" />
                                    <h:outputText styleClass="numPos" value="#{constantaBean.getInterestMetodText(savingApprovalBean.saving.savprod.interestMethod)}" />

                                    <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.maxBalAdmFee}" /><h:outputLabel value=":" />
                                    <h:outputText styleClass="numPos" value="#{savingApprovalBean.saving.savprod.maxBalAdmFee}" >
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                    <h:outputLabel value= "#{bundle.admFee}" /><h:outputLabel value=":" />
                                    <h:outputText styleClass="numPos" value="#{savingApprovalBean.saving.savprod.admFee}" >
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                    <h:outputLabel value= "#{bundle.closingAdmFee}" /><h:outputLabel value=":" />
                                    <h:outputText styleClass="numPos" value="#{savingApprovalBean.saving.savprod.closingAdmFee}" >
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </h:panelGrid>
                            </p:panel>    
                        </h:panelGrid>
                    </h:panelGrid>    
                    
                    <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                        <f:facet name="footer">  
                            <p:commandButton value="#{bundle.approved}" icon="ui-icon-disk" actionListener="#{savingApprovalBean.approve(true)}"
                                update=":#{utilityBean.findClientId('dtSavapprovals')} displaySavapproval"     
                                rendered="#{menuBean.cekButtonAccess(101,'APP;')}" />
                            
                            <p:commandButton value="#{bundle.rejected}" icon="ui-icon-disk" 
                                             actionListener="#{savingApprovalBean.approve(false)}"
                                             rendered="#{menuBean.cekButtonAccess(101,'APP;')}"
                                             update=":#{utilityBean.findClientId('dtSavapprovals')}" />  
                            
                            <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgsaving.hide()" 
                                icon="ui-icon-document" />
                        </f:facet>
                    </h:panelGrid>
                    </h:form>
                </p:dialog> 
            
        </ui:composition>
    </h:body>
</html>